﻿using System;
using System.Configuration;

namespace OrbitOne.CRM
{
    public class CrmConfiguration : ConfigurationSection
    {
        public CrmConfiguration()
        {
        }

        public static CrmConfiguration Load()
        {
            return (CrmConfiguration)ConfigurationManager.GetSection("CrmConfiguration");
        }

        public CrmConfiguration(string url, string username, string password, string domain)
        {
            Url = url;
            Username = username;
            Password = password;
            Domain = domain;
        }

        [ConfigurationProperty("Url", IsRequired = true)]
        public string Url
        {
            get { return (string)this["Url"]; }
            set { this["Url"] = value; }
        }

        [ConfigurationProperty("Username", IsRequired = true)]
        public string Username
        {
            get { return (string)this["Username"]; }
            set { this["Username"] = value; }
        }

        [ConfigurationProperty("Password", IsRequired = true)]
        public string Password
        {
            get { return (string)this["Password"]; }
            set { this["Password"] = value; }
        }

        [ConfigurationProperty("Domain", IsRequired = true)]
        public string Domain
        {
            get { return (string)this["Domain"]; }
            set { this["Domain"] = value; }
        }

        [ConfigurationProperty("Instance", IsRequired = false)]
        public string Instance
        {
            get { return this["Instance"].ToString(); }
            set { this["Instance"] = value; }
        }

        [ConfigurationProperty("AuthenticationType", IsRequired = false)]
        public AuthenticationType AuthenticationType
        {
            get { return (AuthenticationType)this["AuthenticationType"]; }
            set { this["AuthenticationType"] = value; }
        }
    }
}
